<h1>Post</h1>

<%= link_to 'Nuevo Post', new_post_path %>
<% @posts.each do |post| %>
	<%if can? :manage, Post  or post.visible%>
		<div class="blog">
		        <!--start:blog -->
		<%=post.visible%>
		        <h2><%=link_to post.title, post%></h2>
		        <div class="post-info">Posteado por <span><%=post.user.name%> <%=post.user.last_name%></span> el <span><a><%=post.created_at.to_s(:post)%></a></span>, comentarios ( <%=post.comments.count%> ) Nota ( <%=post.rate%> )</div>
		        <p><%= post.content[0,200] %> </p>
		        <%=link_to 'Seguir leyendo', post, :class=>"view"%>
				<td><%= link_to 'Editar', edit_post_path(post) if can? :create, @comment%></td>
				<td><%= link_to 'Eliminar', post, :confirm => 'Esta seguro?', :method => :delete if can? :destroy, @comment%></td>
				<%if can? :manage, Post%>
					<%if post.visible%>
						<%= form_for(post) do |f| %>
						  <%= f.hidden_field :visible,:value => false%>
						  <td><%= f.submit "Ocultar Post" %></td>
						<% end %>
					<%else%>
						<%= form_for(post) do |f| %>
						  <%= f.hidden_field :visible,:value => true%>
						  <td><%= f.submit "Mostrar Post" %></td>
						<% end %>	
					<%end%>
				<%end%>
				<br clear="all" />
				</div>
		  <!--end:blog -->

	<%end%>
<% end %>